import request from '@/utils/request'
import type {
  Coach,
  CreateCoachRequest,
  UpdateCoachRequest,
  CoachListResponse
} from '@/types/api/coach'
import type { BaseResponse, PaginationResponse } from '@/types/common/response'

/**
 * 教练管理相关API
 */
export const coachApi = {
  /**
   * 获取教练列表
   * @param params 查询参数
   */
  getCoachList(params: { page: number; pageSize: number; keyword?: string }) {
    return request.get<BaseResponse<PaginationResponse<Coach>>>('/coaches', { params })
  },

  /**
   * 获取教练详情
   * @param id 教练ID
   */
  getCoachDetail(id: number) {
    return request.get<BaseResponse<Coach>>(`/coaches/${id}`)
  },

  /**
   * 创建教练
   * @param data 教练信息
   */
  createCoach(data: CreateCoachRequest) {
    return request.post<BaseResponse<null>>('/coaches', data)
  },

  /**
   * 更新教练
   * @param id 教练ID
   * @param data 教练信息
   */
  updateCoach(id: number, data: UpdateCoachRequest) {
    return request.put<BaseResponse<null>>(`/coaches/${id}`, data)
  },

  /**
   * 删除教练
   * @param id 教练ID
   */
  deleteCoach(id: number) {
    return request.delete<BaseResponse<null>>(`/coaches/${id}`)
  }
}
